#ifndef BRAIN_PLAN
#define BRAIN_PLAN

class Plan {
public:
	List<FeatureTerm> m_operators;
	List<FeatureTerm> m_precedence_before;		// operator that ocurs before
	List<FeatureTerm> m_precedence_condition;	// condition that links both operators
	List<FeatureTerm> m_precedence_after;		// operator that occurs after



	List<FeatureTerm> *get_unsatisfied_operators(void);
	List<FeatureTerm> *get_unsatisfied_preconditions(FeatureTerm *op);
	List<FeatureTerm> *get_operators_to_satisfy(FeatureTerm *condition,Ontology *o,FTKBase *domain_model);

	void print_orderings(void);
	
	char *toStringNOOS(FTKBase *domain_model);
	void human_readable_print(FTKBase *domain_model);
	Plan *clone(FTKBase *domain_model);
	Plan *clone(FTKBase *domain_model,List<FeatureTerm> *old_nodes,List<FeatureTerm> *new_nodes);
	
	bool check_completeness(void);
	bool check_integrity(Ontology *o,FTKBase *domain_model);
	List<FeatureTerm> *linear_ordering(void);

protected:
	List< List<FeatureTerm> > *linear_orderings(void);
	List< List<FeatureTerm> > *linear_orderings_internal(List<FeatureTerm> *starting_point);
	bool check_linear_integrity(List<FeatureTerm> *linear_plan);
	bool restrictions_violated(Ontology *o,FTKBase *domain_model);
};

#endif
